//
//  JMCarViewCell.m
//  OpenSesame
//
//  Created by zhangjiaming on 16/1/5.
//  Copyright © 2016年 OpenSesame. All rights reserved.
//

#import "JMCarViewCell.h"

@implementation JMCarViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        // 设置cell之间的分割线
        UIView *separater = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JMPhoneWidth, 1)];
        separater.backgroundColor = JMColor(242, 242, 242);
        [self.contentView addSubview:separater];
        
        // 设置车头像
        UIImageView *iconView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 3, 60, 50)];
        [self.contentView addSubview:iconView];
        self.iconView = iconView;
        
        // 设置车钥匙名称Label
        UILabel *keyNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(75, 20, JMPhoneWidth, 16)];
        keyNameLabel.textColor = JMColor(51, 51, 51);
        self.nameLabel = keyNameLabel;
        [self.contentView addSubview:keyNameLabel];
        
        self.height = 60;
        self.backgroundColor = [UIColor clearColor];
        
        // 设置选中时的状态颜色
        UIView *back = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JMPhoneWidth, 60)];
        back.backgroundColor = JMColor(245, 245, 245);
        self.selectedBackgroundView = back;
        self.selectionStyle = UITableViewCellSelectionStyleDefault;
    }
 
    return self;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *ID = @"car";
    JMCarViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[JMCarViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
@end
